<?php include('./templete/public/header.php'); ?>
<title><?php echo $web['site_config']['site_title'].'_'; ?>编辑简历</title>
	<link rel="stylesheet" type="text/css" href="__INDEX__/Mdate/needcss/Mdate.css"/>
	<link rel="stylesheet" type="text/css" href="__INDEX__/district/css/LArea.css"/>

	<!--日期插件-->
	<script src="__INDEX__/datePicker/datePicker.js" type="text/javascript" charset="utf-8"></script>
	<!--地区插件-->
	<script src="__INDEX__/district/js/LArea.js" type="text/javascript" charset="utf-8"></script>
	<script src="__INDEX__/district/js/LAreaData1.js" type="text/javascript" charset="utf-8"></script>
	<script src="__INDEX__/district/js/LAreaData2.js" type="text/javascript" charset="utf-8"></script>
<body>
	<header class="clearfix">
		<a class="fl header_return"><i class="iconzuojiantou1 iconfont">&#xe616;</i>返回</a>
		<a class="header_new">创建简历</a>
		<a class="fr header_more"><i class="iconmore iconfont">&#xe637;</i></a>
	</header>
	<div class="setup_container">
		<form action=" <?php echo url('jianli/create') ;?> " method="post" enctype="multipart/form-data" id="user_form">
			<input type="hidden" name="id" value="<?php echo  $user_data['id'];?>">
			<div class="setup_photo">
				<i class="pr " id="localImag">

					<img id="preview" src="<?php if ($user_data['img_url']): ?><?php echo $user_data['img_url'];?><?php else: ?>__INDEX__/images/setup.jpg<?php endif ?>" width="100%" height="100%"  />
					<a class="iconfont iconxiangji">&#xe671;</a>
					<input type="file" name="img_url" id="doc" value="" class="setup_file"/>
				</i>
			</div>
			<div class="setup_photograph">
                <a class="setup_photograph_text clearfix">
                    <div class="setup_photograph_name fl">
                        简历名称
                    </div>
                    <input type="text" name="jname" id=""  value="<?php echo  $user_data['jname']?:'简历一';?>" />
                </a>
				<a class="setup_photograph_text clearfix">
					<div class="setup_photograph_name fl">
					<i class="red">*</i>姓名
					</div>
					<input type="text" name="name" id=""  value="<?php echo  $user_data['name'];?>" />
				</a>
				<a class="setup_photograph_text clearfix">
					<div class="setup_photograph_name fl">
					<i class="red"></i>英文名
					</div>
					<input type="text" name="en_name" id="" value="<?php echo  $user_data['en_name'];?>" />
				</a>
				<a class="setup_photograph_text clearfix">
					<div class="setup_photograph_name fl">
					<i class="red">*</i>出生年月日
					</div>
					<div class="begin-date">
						<input type="text" name="birthday1" id="" value="<?php echo  ($user_data['birthday1'] != null)?$user_data['birthday1']:'2010';?>"/>
						-
						<input type="text" name="birthday2" id="" value="<?php echo  ($user_data['birthday2'] != null)?$user_data['birthday2']:'01';?>"/>
						-
						<input type="text" name="birthday3" id="" value="<?php echo  ($user_data['birthday3'] != null)?$user_data['birthday3']:'01';?>"/>
					</div>
				</a>
				<a class="setup_photograph_text clearfix bgnone">
					<div class="setup_photograph_name fl">
					<i class="red">*</i>性别
					</div>
					<div class="fr radiobox">
						<span id="sexn" class="pr radio_contaier <?php echo $user_data['sex']==1?'yellow':'' ?>">
							<input type="radio" id="sexn" name="sex" value="1" <?php echo $user_data['sex']==1?'checked':'' ?>  /> 
							<span class="radio_people"><i class="iconfont people">&#xe8a5;</i>男</span>	 
						</span>
						<span id="sexv" class="pr radio_contaier <?php echo $user_data['sex']==0?'yellow':'' ?>">
							<input type="radio" id="sexv" name="sex" value="0" <?php echo $user_data['sex']==0?'checked':'' ?> />  
							<span class="radio_people"><i class="iconfont people">&#xe8a4;</i>女</span>	 
						</span>
					</div>
				</a>
				<a class="setup_photograph_text clearfix">
					<div class="setup_photograph_name fl">
					<i class="red">*</i>身高
					</div>
					<input type="text" name="height" placeholder="cm" value="<?php echo  $user_data['height'];?>" />
				</a>
				<a class="setup_photograph_text clearfix">
					<div class="setup_photograph_name fl">
					<i class="red">*</i>体重
					</div>
					<input type="text" name="weight" placeholder="kg" value="<?php echo  $user_data['weight'];?>" />
				</a>
				<a class="setup_photograph_text clearfix">
					<div class="setup_photograph_name fl">
					<i class="red">*</i>户籍城市
					</div>
					<div class="content-block">
			            <input id="demo1" name="address" type="text" readonly="" placeholder="城市选择"  value="<?php echo  $user_data['address'];?>"/>
			            <input id="value1" type="hidden" value="20,234,504"/>
			        </div>
				</a>
				<a class="setup_photograph_text clearfix">
					<div class="setup_photograph_name fl">
					<i class="red">*</i>现居城市
					</div>
					<div class="content-block">
			            <input id="demo2" name="newaddress" type="text" readonly="" placeholder="城市选择"  value="<?php echo  $user_data['newaddress'];?>"/>
			            <input id="value2" type="hidden" value="20,234,504"/>
			        </div>
				</a>
				<a class="setup_photograph_text clearfix">
					<div class="setup_photograph_name fl">
					<i class="red">*</i>EMAIL
					</div>
					<input type="text" name="email" id="email" value="<?php echo  $user_data['email'];?>" />
				</a>
				<a class="setup_photograph_text clearfix">
					<div class="setup_photograph_name fl">
					<i class="red">*</i>手机
					</div>
					<input type="text" name="tel" id="tel" value="<?php echo  $user_data['tel'];?>" />
				</a>
				<a class="setup_photograph_text clearfix">
					<div class="setup_photograph_name fl">
					<i class="red">*</i>在读学校
					</div>
					<input type="text" name="school"  value="<?php echo  $user_data['school'];?>" />
				</a>
				<a class="setup_photograph_text clearfix">
					<div class="setup_photograph_name fl">
					<i class="red">*</i>专业
					</div>
					<input type="text" name="specialty"  value="<?php echo  $user_data['specialty'];?>" />
				</a>
				<a class="setup_photograph_text clearfix">
					<div class="setup_photograph_name fl">
					<i class="red">*</i>毕业时间
					</div>
					<div class="begin-date">
						<input type="text" name="school_start1" id="" value="<?php echo  ($user_data['school_start1'] != null)?$user_data['school_start1']:'2010';?>" placeholder=""/>
						/
						<input type="text" name="school_start2" id="" value="<?php echo  ($user_data['school_start2'] != null)?$user_data['school_start2']:'09';?>"/>
					</div>
					-
					<div class="end-date">
						<input type="text" name="school_end1" id="" value="<?php echo  ($user_data['school_end1'] != null)?$user_data['school_end1']:'2010';?>" placeholder=""/>
						/
						<input type="text" name="school_end2" id="" value="<?php echo  ($user_data['school_end2'] != null)?$user_data['school_end2']:'06';?>"/>
					</div>
				</a>
				<a class="setup_photograph_text clearfix ">
					<div class="setup_photograph_name fl">
					<i class="red">*</i>每周工作天数
					</div>
					<input type="text" name="working_hours" value="<?php echo  $user_data['working_hours'];?>"  placeholder="（每周可兼职全天天数，包括双休）" />
				</a>
				<hr class="setup_gray"/>
				<div class="sx-experience">
				<?php if (!$user_data['shixi_start1']): ?>
				<div class="append-content">
					<a class="setup_photograph_text clearfix bordernone">
						<div class="setup_photograph_name fl">
						<i class="red"></i>实习经历
						</div>
						
						<div class="begin-date">
							<input type="text" name="shixi_start1[]" id="" value="2010" placeholder="2010"/>
							/
							<input type="text" name="shixi_start2[]" id="" value="01" placeholder="01"/>
						</div>
						-
						<div class="end-date">
							<input type="text" name="shixi_end1[]" id="" value="2010" placeholder="2010"/>
							/
							<input type="text" name="shixi_end2[]" id="" value="01" placeholder="01"/>
						</div>
					</a>
					<a class="setup_photograph_text clearfix">
						<div class="setup_photograph_name fl">
						<i class="red"></i>实习公司
						</div>
						<input type="text" name="shixi_company[]" value="" />
					</a>
					<a class="setup_photograph_text clearfix">
						<div class="setup_photograph_name fl">
						<i class="red"></i>实习职位
						</div>
						<input type="text" name="shixi_zw[]" value="" />
					</a>
					<a class="setup_photograph_text clearfix bordernone">
						<div class="setup_photograph_name fl">
						<i class="red"></i>实习待遇
						</div>
						<input type="text" name="shixi_daiyu[]" value="" />
					</a>
					<hr class="setup_gray"/>
				</div>
				<?php else: ?>
				<?php foreach ($user_data['shixi_start1'] as $key => $o): ?>
				<div class="append-content">
					<a class="setup_photograph_text clearfix bordernone">
						<div class="setup_photograph_name fl">
						<i class="red"></i>实习经历
						</div>
						<div class="begin-date">
							<input type="text" name="shixi_start1[<?php echo $key;?>]" id="" value="<?php echo  $user_data['shixi_start1'][$key];?>" placeholder="2010"/>
							/
							<input type="text" name="shixi_start2[<?php echo $key;?>]" id="" value="<?php echo  $user_data['shixi_start2'][$key];?>" placeholder="01"/>
						</div>
						-
						<div class="end-date">
							<input type="text" name="shixi_end1[<?php echo $key;?>]" id="" value="<?php echo  $user_data['shixi_end1'][$key];?>" placeholder="2010"/>
							/
							<input type="text" name="shixi_end2[<?php echo $key;?>]" id="" value="<?php echo  $user_data['shixi_end2'][$key];?>" placeholder="01"/>
						</div>
					</a>
					<a class="setup_photograph_text clearfix">
						<div class="setup_photograph_name fl">
						<i class="red"></i>实习公司
						</div>
						<input type="text" name="shixi_company[<?php echo $key;?>]" value="<?php echo  $user_data['shixi_company'][$key];?>" />
					</a>
					<a class="setup_photograph_text clearfix">
						<div class="setup_photograph_name fl">
						<i class="red"></i>实习职位
						</div>
						<input type="text" name="shixi_zw[<?php echo $key;?>]" value="<?php echo  $user_data['shixi_zw'][$key];?>" />
					</a>
					<a class="setup_photograph_text clearfix bordernone">
						<div class="setup_photograph_name fl">
						<i class="red"></i>实习待遇
						</div>
						<input type="text" name="shixi_daiyu[<?php echo $key;?>]" placeholder="时薪" value="<?php echo  $user_data['shixi_daiyu'][$key];?>" />
					</a>
					<hr class="setup_gray"/>
				</div>
				<?php endforeach ?>
				</div>
				<a class="add-btn jian" id="b_remove"><img src="__img__/jian.png" width="32px" height="32px"/></a>
				<?php endif ?>

				<a class="add-btn" id="b_add" ><img src="__img__/add.png" width="32px" height="32px"/></a>

				<hr class="setup_gray"/>
				<a class="setup_photograph_text clearfix bordernone">
					<div class="setup_photograph_name fl">
					<i class="red">*</i>语言能力
					</div>
					<input type="text" name="languages" value="<?php echo  $user_data['languages'];?>" />
				</a>
				<a class="setup_photograph_text clearfix">
					<div class="setup_photograph_name fl">
					<i class="red">*</i>求职意向
					</div>
					<input type="text" name="intention" value="<?php echo  $user_data['intention'];?>" />
				</a>
				<a class="setup_photograph_text clearfix">
					<div class="setup_photograph_name fl">
					<i class="red">*</i>自我介绍
					</div>
					<input type="text" name="introduce" value="<?php echo  $user_data['introduce'];?>" />
				</a>
<!--				<a class="setup_photograph_text clearfix" --><?php //if ($user_data['otuijian']): ?><!-- style="display: none;"--><?php //endif ?><!-- >-->
<!--					<div class="setup_photograph_name fl">-->
<!--					<i class="red"></i>推荐码-->
<!--					</div>-->
<!--					<input type="text" id="otuijian" name="otuijian" placeholder="没有推荐码可填万能码0001" value="--><?php //echo  $user_data['otuijian'];?><!--" />-->
<!--				</a>-->
				<a class="setup_photograph_text clearfix" style="background-image: none;overflow: visible;line-height: 22px;font-size: 12px;padding-top: 5px;">
					<div class="setup_photograph_name fl">
					<i class="red"></i>
					</div>
					<b>完整填写简历，确认无误后请选择“发送简历”；<br>如暂不想发送，请选择'暂存简历”。谢谢！</b>
				</a>
			</div>
			<input type="hidden" id="sub_type" name="sub_type" value="">
			<input type="hidden" name="__token__" value="<?php echo session('token') ?>" />
			<a class="setup_new" onclick="user_add(0)" href="javascript:;" style="border-right: 1px solid #fff;width: 50%">暂存简历</a>
			<a class="setup_new" onclick="user_add(1)" href="javascript:;" style="width: 50%;margin-left: 50%">发送简历</a>
			</form>
			
	</div>
	<hr style="height: 80px;border: none;">
	<?php include('./templete/public/footer.php'); ?>
	
</body>
	
</html>
<!-- 防止页面后退（使浏览器后退按钮失效） -->
<!-- <script type="text/javascript">
    jQuery(document).ready(function ($) {
    	if (window.history && window.history.pushState) {
    		$(window).on('popstate', function () {
      　　  		window.history.forward(1);
    　　　　 });
  　　　}
　　});
　</script> -->
<script>

	function user_add(type) {
		document.getElementById("sub_type").value = type;
		var img_url = $("input[ name='img_url'] ").val();
        var preview = $("#preview")[0].src;
        var url_host =window.location.protocol+'//'+ window.location.host;
        if (preview == url_host+'/public/static/index/images/setup.jpg') {
            alert('请上传照片');
            return false;
        }

		var email = document.getElementById('email').value;
		var tel = document.getElementById('tel').value;
		var test_email = /\w[-\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\.)+[A-Za-z]{2,14}/g;
		// var test_tel = /^(13[0-9]|14[5-9]|15[012356789]|166|17[0-8]|18[0-9]|19[8-9])[0-9]{8}$/;// 手机号码校验规则
		var test_tel = /^1[3456789]\d{9}$/;// 手机号码校验规则
		if (!test_email.test(email)) {
            alert('邮箱格式有误');
            return false;
        }
        if (!test_tel.test(tel)) {
        	alert('手机号码格式有误');
            return false;
        }
        var name = $(" input[ name='name'] ").val();
        var birthday1 = $(" input[ name='birthday1'] ").val();
        var birthday2 = $(" input[ name='birthday2'] ").val();
        var birthday3 = $(" input[ name='birthday3'] ").val();
        var address = $(" input[ name='address'] ").val();
        var newaddress = $(" input[ name='newaddress'] ").val();
        var school = $(" input[ name='school'] ").val();
        var specialty = $(" input[ name='specialty'] ").val();
        var school_end1 = $(" input[ name='school_end1'] ").val();
        var school_start1 = $(" input[ name='school_start1'] ").val();
        var school_end2 = $(" input[ name='school_end2'] ").val();
        var school_start2 = $(" input[ name='school_start2'] ").val();
        var working_hours = $(" input[ name='working_hours'] ").val();
        var intention = $(" input[ name='intention'] ").val();
        var introduce = $(" input[ name='introduce'] ").val();
        var languages = $(" input[ name='languages'] ").val();
        var height = $(" input[ name='height'] ").val();
        var weight = $(" input[ name='weight'] ").val();
        var otuijian = $(" input[ name='otuijian'] ").val();
        // if (!otuijian) {
		// 	alert('必填内容不能为空');
		// 	return false;
		// }
        // if (otuijian) {
    	// 	$.ajax({
    	// 		type:"post",
    	// 		data:{'otuijian':otuijian},
    	// 		url:"/index/jianli/checkotuijian",
    	// 		success:function(res) {
    	// 			if (!res) {
    	// 				alert('推荐码错误');
    	// 				return false;
    	// 			}else{
    	// 				if (name && address && newaddress && birthday1 && birthday2 && birthday3 && school && specialty && working_hours && intention && introduce && languages && height && weight && otuijian) {
		// 					document.getElementById("user_form").submit();
		// 				}else{
		// 					alert('必填内容不能为空');
		// 					return false;
		// 				}
		// 		    }
		// 		 }
		// 	})
        // }else{
        	if (name && address && newaddress && birthday1 && birthday2 && birthday3 && school && specialty && working_hours && intention && introduce && languages && height && weight) {
			document.getElementById("user_form").submit();
		}else{
			alert('必填内容不能为空');
			return false;
		}
        // }
	}
	// $(".radio_contaier").click(function(){
	// 			$(this).addClass("yellow").siblings().removeClass("yellow");
	// 			$("input[type='radio'][id=sexn]").attr("checked","checked" );
	// 		})
	$("#sexn").click(function() {
		$("input[type='radio'][id=sexn]").attr("checked","checked" );
		$(this).addClass("yellow");
		$("#sexv").removeClass("yellow");
		$("input[type='radio'][id=sexv]").attr("checked",false );
	})
	$("#sexv").click(function() {
		$(this).addClass("yellow");
		$("#sexn").removeClass("yellow");
		$("input[type='radio'][id=sexv]").attr("checked","checked" );
		$("input[type='radio'][id=sexn]").attr("checked",false );
	})
	$(function() {
		//地区
		//弹出插件时隐藏软键盘
		$("#demo1").focus(function(){
        	document.activeElement.blur();
    	});
		var area1 = new LArea();
		 area1.init({
            'trigger': '#demo1', //触发选择控件的文本框，同时选择完毕后name属性输出到该位置
            'valueTo': '#value1', //选择完毕后id属性输出到该位置
            'keys': {
                id: 'id',
                name: 'name'
            }, //绑定数据源相关字段 id对应valueTo的value属性输出 name对应trigger的value属性输出
            'type': 1, //数据源类型
            'data': LAreaData //数据源
        });
        area1.value=[1,15,3];//控制初始位置，注意：该方法并不会影响到input的value
        var area2 = new LArea();
        area2.init({
            'trigger': '#demo2',
            'valueTo': '#value2',
            'keys': {
                id: 'id',
                name: 'name'
            },
            'type': 1,
            'data': LAreaData //数据源
        });
		area2.value=[1,15,3];//控制初始位置，注意：该方法并不会影响到input的value
		
	
	});

	function load_more(){
		var html=	'<div class="append-content">'+
					'<a class="setup_photograph_text clearfix bordernone">'+
						'<div class="setup_photograph_name fl">'+
							'<i class="red"></i>实习经历'+
						'</div>'+
						'<div class="begin-date">'+
							'<input type="text" name="shixi_start1[]" id="" value="" placeholder="2010"/>'+
							'/'+
							'<input type="text" name="shixi_start2[]" id="" value="" placeholder="01"/>'+
						'</div>'+
						'--'+
						'<div class="end-date">'+
							'<input type="text" name="shixi_end1[]" id="" value="" placeholder="2010"/>'+
							'/'+
							'<input type="text" name="shixi_end2[]" id="" value="" placeholder="01"/>'+
						'</div>'+
					'</a>'+
					'<a class="setup_photograph_text clearfix">'+
						'<div class="setup_photograph_name fl">'+
							'<i class="red"></i>实习公司'+
						'</div>'+
						'<input type="text" name="shixi_company[]" />'+
					'</a>'+
					'<a class="setup_photograph_text clearfix">'+
						'<div class="setup_photograph_name fl">'+
							'<i class="red"></i>实习职位'+
						'</div>'+
						'<input type="text" name="shixi_zw[]" />'+
					'</a>'+ 
					'<a class="setup_photograph_text clearfix">'+
						'<div class="setup_photograph_name fl">'+
							'<i class="red"></i>实习待遇'+
						'</div>'+
						'<input type="text" name="shixi_daiyu[]" />'+
					'</a>'+

					'<hr class="setup_gray"/>'+
					'<div/>';
				
		$(".sx-experience").append(html); 
	}
    
	$('#b_add').on("click",function(){
		load_more();
	})
	$('#b_remove').on("click",function(){
		$(".append-content:last").remove();
	})
	$("input[name='img_url']").on('change',function(){
        var file = $(this).val();
        setImagePreview(file);
    });
    //实现实时预览的函数
 function setImagePreview(avalue) {
    var docObj = document.getElementById("doc");
    //img
    var imgObjPreview = document.getElementById("preview");
    //div
    var divs = document.getElementById("localImag");
    if (docObj.files && docObj.files[0]) {
       //火狐下，直接设img属性
       imgObjPreview.style.display = 'block';
       imgObjPreview.style.width = '100%';
       imgObjPreview.style.height = '100%';
       //imgObjPreview.src = docObj.files[0].getAsDataURL();
       //火狐7以上版本不能用上面的getAsDataURL()方式获取，需要一下方式
       imgObjPreview.src = window.URL.createObjectURL(docObj.files[0]);
     } else {
       //IE下，使用滤镜
       docObj.select();
       var imgSrc = document.selection.createRange().text;
       var localImagId = document.getElementById("localImag");
       //必须设置初始大小
       localImagId.style.width = "100%";
       localImagId.style.height = "100%";
       //图片异常的捕捉，防止用户修改后缀来伪造图片
       try {
           localImagId.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale)"
           localImagId.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = imgSrc;
        } catch(e) {
            alert("您上传的图片格式不正确，请重新选择!");
            return false;
        }
        imgObjPreview.style.display = 'none';
        document.selection.empty();
     }
   return true;
}
</script>
